#include "qwindowmanager.h"

QWindowManager::QWindowManager(QObject *parent) : QObject(parent)
{
    // engine->rootContext()->setContextProperty("WindowManager", this);
}


Q_INVOKABLE void QWindowManager::newWindow(QString name, QUrl url)
{
    if (windowsMap.contains(name))
    {
        return;
    }

    QQmlApplicationEngine *engine = new QQmlApplicationEngine();
    engine->load(url);
    windowsMap.insert(name, engine);
    return;
}

Q_INVOKABLE QQmlApplicationEngine *QWindowManager::getWindow(QString name)
{
    if (windowsMap.contains(name))
    {
        QQmlApplicationEngine *engine = windowsMap.value(name);
        return engine;
    }
    else
    {
        return nullptr;
    }
}


